home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13778 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news1.interserv.net!news
  2. From: <dvisage@interserv.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Get name of OCX container
  5. Date: 27 Mar 1996 12:09:43 GMT
  6. Organization: InterServ News Service
  7. Message-ID: <4jbb67$jrn@lal.interserv.net>
  8. NNTP-Posting-Host: ad16-083.compuserve.com
  9. Content-Type: text/plain
  10. Keywords: OCX
  11. Content-length: 767
  12. X-Newsreader: AIR Mosaic (32-bit) 4.00
  13.  
  14.  
  15. >I would like to obtain application specific data, primarily, what is
  16. >the name of the current application in which I (as an OCX Control) am
  17. >contained in?
  18. >
  19.  
  20. If you can get a CWnd* to your OCX , you should be able to get the parent HWND.  If you have the HWND of the parent
  21. window, you should be able to get the HINSTANCE.  If you have the HINSTANCE, you should be able to get the name of
  22. the executable module :
  23.  
  24. I think the calls you need are :
  25.  
  26. CWnd* cw;                       //  This is your OCX control
  27. HINSTANCE hInst;
  28. HWND hWnd;
  29. char name[255];
  30.  
  31. hWnd = ::GetParent(cw->m_hwnd);
  32.  
  33. hInst  = (HINSTANCE) ::GetWindowLong(hWnd, GWL_HINSTANCE);
  34.  
  35. ::GetModuleFileName(hinst, name, 255);
  36.  
  37. There is probably a better way to do this using MFC. 
  38.  
  39.  
  40.